import { Component, OnInit, ViewChild, ViewContainerRef, Renderer2 } from '@angular/core';
import { HttpHelper } from '../../../Helper/HttpHelper';
import { SmartTableDataSource } from '../../../Helper/SmartTableDataSource';
import { Fun } from '../../../Config/Fun';
import { DtoResultObj } from '../../../Model/DtoRec/DtoResult';
import { NbWindowService } from '@nebular/theme';
import { ServerSourceConf } from '../../../Lib/ng2-smart-table/lib/lib/data-source/server/server-source.conf';
import { Variables } from '../../../../../src/app/Config/Variables';
import { LocalDataSource } from 'src/app/Lib/ng2-smart-table/public-api';

@Component({
  selector: 'wzl-teacher-course-report',
  templateUrl: './teacher-course-report.html',
})
export class TeacherCourseReportComponent implements OnInit {
  @ViewChild('samrtTable', { static: true, read: ViewContainerRef }) container: ViewContainerRef;
  @ViewChild('btnHead', { static: true }) template;
  source: LocalDataSource;
  /** 静态方法，获取默认配置 */
  settings: any = SmartTableDataSource.getDefaultSetting();
  bean = {
    dtStart: "",
    dtEnd: ""
  }
  constructor(
    private HttpHelper: HttpHelper,
    private windowService: NbWindowService,
    public httpHelper: HttpHelper,
    private renderer: Renderer2
  ) {
    let configJson = {
      "name": {
        "title": '姓名'
      },
      "num": {
        "title": '总课时'
      },
      "w1": {
        "title": '周一课时'
      },
      "w2": {
        "title": '周二课时'
      },
      "w3": {
        "title": '周三课时'
      },
      "w4": {
        "title": '周四课时'
      },
      "w5": {
        "title": '周五课时'
      },
      "w6": {
        "title": '周六课时'
      },
      "cancelNum": {
        "title": '取消课时'
      }
    }

    this.settings.columns = configJson;
    this.settings.actions = null;
    this.settings.pager["perPage"] = 1000;

  }

  ngOnInit() {

  }

  async onSave(event): Promise<void> {
    alert("save");
  }

  /**
   * 
   * @param event 添加事件
   */
  onDelete(event): void {
    alert("delete");
  }

  Search(): void {
    this.httpHelper.Post("Report/TeacherAllCourseReport", this.bean).then((result: DtoResultObj<string>) => {
      Fun.HideLoading();
      if (result.success) {
        this.source = new LocalDataSource(result.dataList);
      }
      else {
        Fun.Hint(result.msg);
      }
      console.log(result);
    })
  }
}
